The present invention relates to USB data acquisition (DAQ) systems, and particularly to a virtual DMA implementation which emulates a direct memory access (DMA) device in software for improved USB data acquisition performance.
Scientists and engineers often use DAQ systems to perform a variety of functions, including laboratory research, process monitoring and control, data logging, analytical chemistry, test and analysis of physical phenomena, and control of mechanical or electrical machinery, to name a few examples.
A typical DAQ system comprises a computer system with DAQ hardware, wherein the DAQ hardware is typically plugged into one of the I/O slots of the computer system. A DAQ system also typically includes transducers and other detecting means for providing xe2x80x9cfieldxe2x80x9d electrical signals representing a process, physical phenomena, equipment being monitored or measured, etc. The field signals are provided to the DAQ hardware. In another common DAQ system configuration, the DAQ hardware is coupled to the computer system via other means such as through a VXI (VME extensions for Instrumentation) bus, a GPIB (General Purpose Interface Bus), a serial port, or parallel port of the computer system. Optionally, the DAQ system includes signal conditioning modules which receive the field signals and condition the signals to be acquired.
The DAQ hardware is configured and controlled by DAQ software executing on the computer system. The DAQ software for configuring and controlling the DAQ system typically comprises two portions: the device interface or driver level software and the application software, or the application. The driver level software serves to interface the DAQ hardware to the application. The driver level software is typically supplied by the manufacturer of the DAQ hardware or by some other third party software vendor. An example of DAQ driver level software is NI-DAQ from National Instruments Corporation. The application or client is typically developed by the user of the DAQ system and is tailored to the particular function which the user intends the DAQ system to perform. The DAQ hardware manufacturer or third party software vendor sometimes supplies the application software for certain applications which are common, generic or straightforward.
The Universal Serial Bus is a serial peripheral bus standard developed for computer system peripheral devices. The USB is an external serial bus which supports data exchange between a host computer and a wide range of peripheral devices. The USB provides two wire, point-to-point signaling in which the signals are differentially driven at a bit rate of 12 megabits per second.
USB systems are generally defined in terms of (1) interconnects, (2) devices, and (3) hosts. The USB interconnect defines the manner in which the USB devices are connected to and communicate with the USB host. The host computer system USB interface is referred to as the host controller. The host controller may be implemented in a combination of hardware, firmware, or software. USB devices are defined as (1) hubs, which provide additional attachment points to the USB, or (2) functions, which provide capabilities to the system; e.g., an ISDN connection, a digital joystick, or speakers. Hubs indicate the attachment or removal of a USB device in its per port status bit. The host determines if a newly attached USB device is a hub or a function and assigns a unique USB address to the USB device. All USB devices are accessed by a unique USB address. Each device additionally supports one or more endpoints with which the host may communicate. The remaining description will be limited to USB devices defined as functions.
The USB supports functional data and control exchange between the USB host and USB devices. USB data transfers take place between host software and a particular endpoint on a USB device. The USB host, e.g., the host computer system, interacts with USB devices through the host controller. The host controller is responsible for detecting the attachment and removal of USB devices, managing control flow between the host and USB devices, managing data flow between the host and USB devices, collecting status and activity statistics, and providing a limited amount of power to attached USB devices. The USB system software on the host manages interactions between the USB devices and device software. Further background concerning the USB may be obtained from USB Specification, Revision 1.0 which is incorporated herein by reference.
In prior art systems, e.g., prior art instrumentation systems, the host CPU obtains data from a peripheral device, such as a data acquisition card, using either DMA transfers or interrupt driven requests. DMA transfers typically use burst transfers for improved performance. However, for interrupt driven requests, the host software is typically required to read one sample at a time. In other words, for interrupt drive requests, host software is typically configured to read data one sample at a time from a local peripheral device, e.g., from a PCI DAQ device.
DMA transfers have generally not been possible for USB transfers between a host computer system and a USB device. This is because USB does not provide true DMA support. Thus, for USB transfers, the host controller typically utilizes existing driver level software which operates to read or communicate data with the USB device either one sample at a time or a buffer of data which is passed to the NI-DAQ driver one sample at a time. Thus, when this existing driver level software is used, the host controller has generally been required to read data from a USB DAQ device one sample at a time across the USB.
However, due to the high latencies of the USB, a read of one sample at a time results in slow data transfer rates. For example, the time required to read 100,000 samples from the USB device would be no faster than 100,000 samples times 0.003 seconds/sample which equals 300 seconds, i.e., 333 samples per second. Thus, simple data acquisition tasks using a USB DAQ device take a very large amount of time. Alternatively, the existing driver level software can be modified to take advantage of USB packet transfers. However, this may require a large modification to existing software, which is undesirable.
U.S. patent application Ser. No. 09/062,893 titled xe2x80x9cSystem and Method for Optimizing Serial USB Device Reads Using Virtual FIFO Techniquesxe2x80x9d discloses virtual buffer techniques for greatly improving the performance of USB devices with minimal software changes. The virtual buffer software increases USB data transfer rates in the USB-based data acquisition system with minimal changes to DAQ driver level software. The virtual buffer software operates to receive or intercept calls made by the DAQ driver level software to acquire data from the device. The virtual buffer software intercepts the call and requests the data in bulk packets from the device. The virtual buffer software then receives the bulk packets and stores the received packets of data in a virtual buffer or virtual FIFO maintained in computer system memory. When a determined amount of data is stored in the virtual FIFO, the virtual buffer software generates an interrupt to the driver software. The driver software then reads the data one sample at a time from the computer memory. These reads occur much more quickly, since the data is read from computer memory instead of from the USB device across the USB bus.
The virtual buffer software emulates operation of the device, including generation of interrupts and responses to status register reads, thus xe2x80x9cfoolingxe2x80x9d the DAQ driver level software into thinking the data is being acquired from the device. Thus, the above application discloses a system which allows for much faster data transfers, while requiring minimal or no changes to the existing DAQ driver level software.
However, this virtual buffer technique involved transferring data from the virtual FIFO (in computer memory) to the driver software (at another location in computer memory) one sample at a time. This was primarily because the existing driver level software was designed to read one sample at a time, and it was undesirable to change the driver level software.
DMA techniques involve acquiring data in large packets and providing these large packets directly a memory location specified by the requesting software. Thus, DMA techniques would provide increased performance 500% over virtual buffer techniques. However, as noted above, DMA techniques are generally not possible in USB systems.
Therefore, an improved system and method is desired which provides increased performance for USB devices. It is also desirable to improve the performance of USB devices with minimal impact on existing software and drivers. It is further desirable to provide DMA-type performance in USB systems.
The present invention comprises a system and method for emulating DMA operations in software for improved data transfers. The system and method operate in a data acquisition system comprising a computer system and a device coupled to the computer system through a serial bus. The serial bus is preferably the Universal Serial Bus (USB), and the device is preferably a USB DAQ device. The computer system includes driver software, preferably DAQ driver level software, and serial bus driver software, preferably USB software. The computer system also includes virtual DMA software according to the present invention.
The virtual DMA software increases USB data transfer rates in the USB-based data acquisition system with minimal changes to DAQ driver level software. The virtual DMA software operates to receive or intercept calls made by an application or the DAQ driver level software to configure a hardware DMA device. The virtual DMA software intercepts the call and provides a virtual DMA implementation for improved performance. Thus, the computer system may not include a hardware DMA device, and the virtual DMA software emulates operation of the hardware DMA device. The virtual DMA software emulates operation of the hardware DMA device invisibly to both the application and the driver software. The virtual DMA software also operates without substantial modification to the driver software. Thus driver software which presumes the use of hardware DMA can still operate in systems where hardware DMA is not possible.
An application executing in the computer system first makes a call to program a DMA controller to perform an acquisition of data, wherein the call includes one or more addresses in computer memory. When the application makes the call, the virtual DMA software receives the call and requests the data from the device in one or more packets. When the data is received, the virtual DMA software stores the data in the computer memory at the one or more addresses. The virtual DMA software may then generate an interrupt to the device driver software indicating that the data is stored in the computer memory.
The DAQ driver level software thus obtains the data from the computer system memory using much faster transfers, e.g., up to 500,000 bytes per second. The virtual DMA emulates a hardware DMA operation, thus xe2x80x9cfoolingxe2x80x9d the DAQ driver level software into thinking the data is being acquired from the device using DMA. Thus, the present invention allows for much faster data transfers, while requiring minimal or no changes to the existing DAQ driver level software.